<?php
	//GLOBALS MUST BE HERE BEFORE THE COMMON.PHP FILE.
	$projects_folder = "./projects/";

	include_once "boiler_plate/common.php"; //MUST ALWAYS BE THE LAST INCLUDE
	//----------------------------------------------------------------------

	function mysql_reverse_db($scheme, $database, $username, $password){
		var erd = array(
					  "name"					=> $database
					, "database_type"			=> "mysql"
					, "implementation_fields"	=> array("created_by","created_on","last_edit_by","last_edit_on","last-edit_on")
					, "erd"						=> array(
														array(
															  "name"		=> "ERD"
															, "entities"	=> array()
														)
													)
				);
		
		
	}
	
	function mysql_read_tables($db){
		
	}
	
	function mysql_read_foreign_keys($db, $schema, $table){
		$sql = "SELECT i.TABLE_NAME, COLUMN_NAME, ".
				" k.REFERENCED_TABLE_NAME, k.REFERENCED_COLUMN_NAME ".
				" FROM information_schema.TABLE_CONSTRAINTS i ".
				" LEFT JOIN information_schema.KEY_COLUMN_USAGE k ".
				"			ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME ".
				" WHERE i.CONSTRAINT_TYPE = 'FOREIGN KEY' ".
				" AND i.TABLE_SCHEMA = '".$schema."' ".
				" AND i.TABLE_NAME = '".$table."'";
		
	}
	
?>
